package com.ruoyi.aslife.controller;

import com.ruoyi.aslife.domain.AS_User;
import com.ruoyi.aslife.service.IAS_UserService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户信息管理Controller
 * 
 * @author ruoyi
 * @date 2022-12-01
 */
@RestController
@RequestMapping("/api")
public class AS_UserController_user extends BaseController
{
    @Autowired
    private IAS_UserService aS_UserService;

    /**
     * 查询用户信息管理列表
     */
    @GetMapping("/user/list")
    public TableDataInfo list(AS_User aS_User)
    {
        startPage();
        List<AS_User> list = aS_UserService.selectAS_UserList(aS_User);
        return getDataTable(list);
    }


    /**
     * 获取用户信息管理详细信息
     */

    @GetMapping(value = "/user/{uid}")
    public AjaxResult getInfo(@PathVariable("uid") Long uid)
    {
        return success(aS_UserService.selectAS_UserByUid(uid));
    }

    /**
     * 新增用户信息管理
     */
    @Log(title = "用户信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AS_User aS_User)
    {
        return toAjax(aS_UserService.insertAS_User(aS_User));
    }

    /**
     * 修改用户信息管理
     */
    @Log(title = "用户信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AS_User aS_User)
    {
        return toAjax(aS_UserService.updateAS_User(aS_User));
    }

    /**
     * 删除用户信息管理
     */
    @Log(title = "用户信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uids}")
    public AjaxResult remove(@PathVariable Long[] uids)
    {
        return toAjax(aS_UserService.deleteAS_UserByUids(uids));
    }
}
